//
// Created by yangchao on 2022/5/13.
// 28. 实现 strStr(): https://leetcode.cn/problems/implement-strstr/
//

#include <string>
using namespace std;

class StrStr{
public:
    //KMP算法实现
    int strStrKMP(string haystack, string needle) {

    }

    int strStr(string haystack, string needle) {
        int n = haystack.size(), m = needle.size();
        for (int i = 0; i <= n-m; ++i) {
            bool flag = true;
            for (int j = 0; j < m; ++j) {
                if (haystack[i+j] != needle[j]) {
                    flag = false;
                    break;
                }
            }
            if (flag) return i;
        }
        return -1;
    }
};

